package com.example.springboot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springboot.entity.Order;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface OrderMapper extends BaseMapper<Order> {
    @Select("SELECT * from `order`")
    List<Order> findAll();
    @Insert("INSERT into `order`(oid,uname,ISBN,quantity,did) VALUES(#{oid},#{uname},#{ISBN},#{quantity},#{did})")
    int insert(Order order);
    @Update("UPDATE `order` SET oid=#{oid},uname=#{uname},ISBN=#{ISBN},quantity=#{quantity},did=#{did}")
    boolean update(Order order);
    @Delete("DELETE FROM `order` WHERE oid=#{oid}")
    Integer deleteByOid(@Param("oid") Long oid);
    @Select("SELECT * FROM `order` WHERE oid=#{oid}")
    List<Order> findByOid(Long oid);
    @Select("SELECT * FROM `order` WHERE uname=#{uname}")
    List<Order> findByUname(String uname);
    @Select("SELECT * FROM `order` WHERE did=#{did}")
    List<Order> findByDid(Long did);
    @Delete("DELETE FROM `order` WHERE did=#{did}")
    Integer deleteByDid(Long did);
}
